package ae.pcfc.cldos.online.common.facade.provider;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import ae.pcfc.cldos.online.common.custom.annotations.PostInitialize;
import ae.pcfc.cldos.online.common.facade.BaseFacade;
import ae.pcfc.cldos.online.common.facade.SystemValuesFacade;
import ae.pcfc.cldos.online.common.prdb.domain.SystemValues;
import ae.pcfc.cldos.online.common.prdb.domain.manager.SystemValuesDOM;
import ae.pcfc.cldos.online.common.vo.selectors.SystemValuesVO;

/**
 * System values facade implementation
 * 
 * @author arosa
 *
 */
public class SystemValuesFacadeImpl extends BaseFacade implements SystemValuesFacade {

	private SystemValuesDOM systemValuesDOM;

	public void setSystemValuesDOM(SystemValuesDOM systemValuesDOM) {
		this.systemValuesDOM = systemValuesDOM;
	}

	private static final String __ABSCOND_STATUS = "ABSCONDSTATUS";
	private static final String __BG_FLAG = "BGFLAG";
	private static final String __DEPT_CODE = "DEPT_CODE";
	private static final String __EDNRD_STATUS = "EDNRD_STATUS";
	private static final String __EMP_SOURCE = "EMPSOURCE";
	private static final String __EMP_TYPE = "EMPTYPE";
	private static final String __EMP_LEAVING_REASON = "EmpLeavingReason";
	private static final String __GENDER = "GENDER";
	private static final String __QUALIFICATION = "QUALIFICATION";
	private static final String __RENW_RP_STATUS = "RENW_RP_STATUS";
	private static final String __RP_STATUS = "RP_STATUS";
	private static final String __TITLE = "TITLE";
	private static final String __MARITAL_STATUS = "MARITALSTATUS";
	private static final String __MED_AGENT = "MEDAGENT";
	private static final String __MEDICAL_TYPE = "MEDICALTYPE";
	private static final String __MED_APP_FIXED = "MED_APP_FIXED";
	private static final String __OCCUPATION = "OCCUPATION";
	private static final String __OPTION = "OPTION";
	private static final String __ACCOM_STATUS = "ACCOM_STATUS";
	private static final String __BAN_PERIOD = "BANPERIOD";
	private static final String __CERTIFICATE = "CERTIFICATE";
	private static final String __CURRENT_VISA = "CURRENTVISA";
	private static final String __EMIRATES = "EMIRATES";
	private static final String __IMMIGRATION_PORT = "IMMIGRATION_PORT";
	private static final String __JOB_CODE = "JOBCODE";
	private static final String __RELATIONSHIP = "RELATIONSHIP";
	private static final String __RELIGION = "RELIGION";
	private static final String __RP_PERIOD = "RPPERIOD";
	private static final String __SIGNATURE = "SIGNATURE";
	private static final String __VISA_TYPE = "VISATYPE";
	private static final String __LANGUAGE = "LANGUAGE";
	private static final String __MED_FIXED_RENEWAL = "MED_FIXED_RENEWAL";
	private static final String __NEW_RP_STATUS = "NEW_RP_STATUS";
	private static final String __PRIORITY = "PRIORITY";

	private Map<String, List<SystemValuesVO>> systemValuesCacheMap;

	@PostInitialize
	@Transactional
	public void postInitialize() {
		Map<String, List<SystemValuesVO>> lcSystemValuesCacheMap = new HashMap<String, List<SystemValuesVO>>(
				20);
		List<String> types = systemValuesDOM.getTypes();
		for(String type : types){
			List<SystemValues> systemValues = systemValuesDOM.getSystemValuesByTypeName(type);
			List<SystemValuesVO> systemValuesVOs = new ArrayList<SystemValuesVO>(systemValues.size());
			for(SystemValues systemValue : systemValues){
				SystemValuesVO systemValuesVO = new SystemValuesVO();
				getMapper().map(systemValue, systemValuesVO);
				systemValuesVOs.add(systemValuesVO);
			}
			
			lcSystemValuesCacheMap.put(type, systemValuesVOs);
		}
		systemValuesCacheMap = lcSystemValuesCacheMap; 
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getAccomodationStatus() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__ACCOM_STATUS)) ? systemValuesCacheMap
				.get(__ACCOM_STATUS) : Collections.emptyList());
	}

	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getAbscondStatus() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__ABSCOND_STATUS)) ? systemValuesCacheMap
				.get(__ABSCOND_STATUS) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getBanPriod() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__BAN_PERIOD)) ? systemValuesCacheMap
				.get(__BAN_PERIOD) : Collections.emptyList());
	}

	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getBGFlag() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__BG_FLAG)) ? systemValuesCacheMap
				.get(__BG_FLAG) : Collections.emptyList());
	}

	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getCertificate() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__CERTIFICATE)) ? systemValuesCacheMap
				.get(__CERTIFICATE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getCurrentVisa() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__CURRENT_VISA)) ? systemValuesCacheMap
				.get(__CURRENT_VISA) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getDepartmentCode() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__DEPT_CODE)) ? systemValuesCacheMap
				.get(__DEPT_CODE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getEDNRDStatus() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__EDNRD_STATUS)) ? systemValuesCacheMap
				.get(__EDNRD_STATUS) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getEmirates() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__EMIRATES)) ? systemValuesCacheMap
				.get(__EMIRATES) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getEmployeeLeavingReason() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__EMP_LEAVING_REASON)) ? systemValuesCacheMap
				.get(__EMP_LEAVING_REASON) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getEmployeeSource() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__EMP_SOURCE)) ? systemValuesCacheMap
				.get(__EMP_SOURCE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getEmployeeType() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__EMP_TYPE)) ? systemValuesCacheMap
				.get(__EMP_TYPE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getGender() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__GENDER)) ? systemValuesCacheMap
				.get(__GENDER) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getImmigrationPort() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__IMMIGRATION_PORT)) ? systemValuesCacheMap
				.get(__IMMIGRATION_PORT) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getJobCode() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__JOB_CODE)) ? systemValuesCacheMap
				.get(__JOB_CODE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getLanguage() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__LANGUAGE)) ? systemValuesCacheMap
				.get(__LANGUAGE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getMaritalStatus() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__MARITAL_STATUS)) ? systemValuesCacheMap
				.get(__MARITAL_STATUS) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getMedAgent() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__MED_AGENT)) ? systemValuesCacheMap
				.get(__MED_AGENT) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getMedAppFixed() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__MED_APP_FIXED)) ? systemValuesCacheMap
				.get(__MED_APP_FIXED) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getMedFixedRenewal() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__MED_FIXED_RENEWAL)) ? systemValuesCacheMap
				.get(__MED_FIXED_RENEWAL) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getMedicalType() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__MEDICAL_TYPE)) ? systemValuesCacheMap
				.get(__MEDICAL_TYPE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getNewRPStatus() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__NEW_RP_STATUS)) ? systemValuesCacheMap
				.get(__NEW_RP_STATUS) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getOccupation() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__OCCUPATION)) ? systemValuesCacheMap
				.get(__OCCUPATION) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getOption() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__OPTION)) ? systemValuesCacheMap
				.get(__OPTION) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getPriority() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__PRIORITY)) ? systemValuesCacheMap
				.get(__PRIORITY) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getQualification() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__QUALIFICATION)) ? systemValuesCacheMap
				.get(__QUALIFICATION) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getRelationship() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__RELATIONSHIP)) ? systemValuesCacheMap
				.get(__RELATIONSHIP) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getReligion() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__RELIGION)) ? systemValuesCacheMap
				.get(__RELIGION) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getRenewRPStatus() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__RENW_RP_STATUS)) ? systemValuesCacheMap
				.get(__RENW_RP_STATUS) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getRPPeriod() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__RP_PERIOD)) ? systemValuesCacheMap
				.get(__RP_PERIOD) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getRPStatus() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__RP_STATUS)) ? systemValuesCacheMap
				.get(__RP_STATUS) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getSignature() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__SIGNATURE)) ? systemValuesCacheMap
				.get(__SIGNATURE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getTitle() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__TITLE)) ? systemValuesCacheMap
				.get(__TITLE) : Collections.emptyList());
	}
	
	@SuppressWarnings("unchecked")
	public List<SystemValuesVO> getVisaType() {
		return (List<SystemValuesVO>) ((systemValuesCacheMap
				.containsKey(__VISA_TYPE)) ? systemValuesCacheMap
				.get(__VISA_TYPE) : Collections.emptyList());
	}
	

	
}
